<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>扩展操作符</title>
    </head>
    <body>
        <h1>扩展操作符</h1>
        <p>来源:<a href="https://github.com/dvajs/dva-knowledgemap">https://github.com/dvajs/dva-knowledgemap</a></p>
        <script>
            // 用于组装数组
            const todos=['redpackage','h5live'];
            const todoList = [...todos,'dva','redux'];
            console.log(`我要做的事情有：${todoList}`);
            // 用于获取数组的一部分
            const [first,...rest]=todoList;
            console.log(rest);
            const [one,,third] = todoList;
            console.log(third);
            // 收集函数参数为数组
            function setMarry(one,...rest){
                console.log(rest);
            }
            setMarry('小敏','小花','Marry','John','Marck');
            // 组成新的对象
            const foo = {
              a: 1,
              b: 2,
            };
            const bar = {
              b: 3,
              c: 2,
            };
            const d = 4;

            const ret = { ...foo, ...bar, d };  // { a:1, b:3, c:2, d:4 }
        </script>
    </body>
</html>